/*
 *  $Id: StoneRitual.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System.Collections.Generic;

namespace Ragima.Cards001.Earth.Spells {
    public class StoneRitual: SpellCard {
        public StoneRitual(): base("001_e_s_stone_ritual") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Earth;
            Value = 100;
            AddManaCost(ElementType.Earth, 3);
        }

        public override void DoAction(TargetArgs args) {
            DoRitual(args.Player);
            DoRitual(args.Player.Enemy);
        }

        private static readonly Languages.CardPhrase<StoneRitual> Action = new Languages.CardPhrase<StoneRitual>("action");

        private static void DoRitual(Player owner) {
            if (owner.Lands.Count == 0)
                return;
            List<Land> lands = new List<Land>(owner.GetLandsWithoutAntimagic());
            if (lands.Count == 0)
                return;
            Game.Current.Log.Add(Action.Phrase, owner, lands.Count);
            ElementValues manas = new ElementValues();
            foreach (Land land in lands) {
                land.Card.AddSumMana(manas);
                land.Remove();
            }
            foreach (ElementType element in ElementType.AllElements)
                if (manas[element] > 0)
                    owner.IncrementMana(element, manas[element]);
        }
    }
}
